'use strict';

module.exports = app => {
  const mongoose = app.mongoose;
  const Schema = mongoose.Schema;
  const ObjectId = Schema.ObjectId;

  const ChatRoomSchema = new Schema({
    to_user_id: { type: ObjectId },
    from_user_id: { type: ObjectId },
    order_id: { type: ObjectId },
    state: { type: String },
    from_count: { type: Number, default: 0 },
    to_count: { type: Number, default: 0 },
    create_at: { type: Date, default: Date.now },
    update_at: { type: Date, default: Date.now },
    close: { type: Boolean, default: false },
    deleted: { type: Boolean, default: false },
  });

  return mongoose.model('ChatRoom', ChatRoomSchema);
};
